package com.shaunstone.web.sports.dal.model;

import java.io.Serializable;

import javax.persistence.*;

import org.hibernate.annotations.Cascade;

import com.shaunstone.web.sports.dal.model.enums.Sports;

import java.util.List;

/**
 * The persistent class for the league database table.
 * 
 */
@Entity
@Table(name = "league")
@NamedQuery(name = "League.findAll", query = "SELECT l FROM League l")
public class League implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;

	private String name;

	@Enumerated(EnumType.STRING)
	private Sports sport;

	// bi-directional many-to-many association to Division
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "league_division_mapping", joinColumns = { @JoinColumn(name = "league_id") }, inverseJoinColumns = { @JoinColumn(name = "division_id") })
	private List<Division> divisions;

	public League() {
	}

	public League(int id, String name, Sports sport, List<Division> divisions) {
		super();
		this.id = id;
		this.name = name;
		this.sport = sport;
		this.divisions = divisions;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Division> getDivisions() {
		return this.divisions;
	}

	public void setDivisions(List<Division> divisions) {
		this.divisions = divisions;
	}

	public Sports getSport() {
		return sport;
	}

	public void setSport(Sports sport) {
		this.sport = sport;
	}
}